﻿@using AC.Service.DTO.LiCai
@model wychuan2.com.Areas.admin.Models.LiCai.BillModel
@{
    ViewBag.Title = "理财-明细";
    Layout = "../Shared/_Layout.cshtml";
}

@{
    List<ItemDTO> lstBooks = Model.Items.Where(m => m.Type == ItemType.BillBook).ToList();
    List<ItemDTO> lstProjects = Model.Items.Where(m => m.Type == ItemType.Project).ToList();
    List<ItemDTO> lstMembers = Model.Items.Where(m => m.Type == ItemType.Member).ToList();
    List<ItemDTO> lstBusiness = Model.Items.Where(m => m.Type == ItemType.Business).ToList();
    string strCategories = AC.Util.JsonHelper.ToJson(Model.Categories);
    
    var lstExpends = Model.Categories.Where(c => c.InOutType == CategoryType.Expend && c.ParentId == 0).OrderByDescending(c => c.IsCommonUse);
    var lstExpendsChilds = Model.Categories.Where(c => c.ParentId == lstExpends.FirstOrDefault().Id).OrderByDescending(c => c.IsCommonUse);

    var lstIncomes = Model.Categories.Where(c => c.InOutType == CategoryType.Income && c.ParentId == 0).OrderByDescending(c => c.IsCommonUse);
    var lstIncomesChilds = Model.Categories.Where(c => c.ParentId == lstIncomes.FirstOrDefault().Id).OrderByDescending(c => c.IsCommonUse);
}

@section styles{
    <link href="~/Content/plugins/iCheck/custom.css" rel="stylesheet">
    @*<link href="~/Content/plugins/datetimepicker/jquery.datetimepicker.css" rel="stylesheet" />*@
    <link href="~/Content/plugins/datapicker/datepicker3.css" rel="stylesheet" />
    <link href="~/Content/plugins/mobiscroll/mobiscroll.custom-2.5.2.min.css" rel="stylesheet" />

    <style type="text/css">
        .ibox-bill {
            margin-bottom: 10px;
        }

        .ibox-title-bill {
            border-top: none !important;
        }

        .bill-item-day {
        }

        .bill-item-list {
        }

        .bill-item {
            display: block;
            padding: 0px;
            margin-bottom: 2px;
            background: #fff;
            border-bottom: 1px solid #f1f1f1;
        }

            .bill-item a {
                font-size: 14px;
                font-weight: 600;
                /*color: #1ab394;*/
                display: block;
            }

        .bill-item-price {
            font-size: 17px;
            line-height: 18px;
            font-weight: 200;
        }
    </style>
}
<div class="row">
    <div class="col-lg-12">
        <div class="ibox">
            <div class="ibox-content">
                <ul class="nav nav-tabs" role="tablist">
                    <li class="active" role="presentation"><a href="#tabAll" data-toggle="tab">全部</a></li>
                    <li role="presentation"><a href="#tab1" role="tab" data-toggle="tab">支出</a></li>
                    <li role="presentation"><a href="#tab2" role="tab" data-toggle="tab">收入</a></li>
                    <li role="presentation"><a href="#tab3" role="tab" data-toggle="tab">转账</a></li>
                    <li role="presentation"><a href="#tab4" role="tab" data-toggle="tab">借贷</a></li>
                </ul>

                <div class="tab-content">
                    <div role="tabpanel" class="tab-pane active J_Tab" data-billtype="0" id="tabAll">
                        <div class="ibox float-e-margins J_hide">
                            <div class="ibox-title ibox-title-bill">
                                <h5 class="text-danger">查询条件</h5>
                                <div class="ibox-tools">
                                    <div class="btn-group">
                                        <button name="btnLastedWeek" data-querytype="1" type="button" class="btn btn-xs btn-white active">最近一周</button>
                                        <button name="btnLastedMonth" data-querytype="2" type="button" class="btn btn-xs btn-white">最近一月</button>
                                    </div>

                                    <a class="collapse-link ui-sortable">
                                        <i class="fa fa-chevron-up"></i>
                                    </a>
                                </div>
                            </div>
                            <div class="ibox-content">
                                <form class="form-inline">
                                    <div class="form-group">
                                        <div class="input-daterange input-group" id="datepicker">
                                            <input type="text" class="input-sm form-control" name="start" value="@DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd")" />
                                            <span class="input-group-addon">to</span>
                                            <input type="text" class="input-sm form-control" name="end" value="@DateTime.Now.ToString("yyyy-MM-dd")" />
                                            <span class="input-group-btn">
                                                <button name="btnDateQuery" type="button" class="btn btn-primary btn-sm "><i class="fa fa-search"></i></button>
                                            </span>
                                        </div>
                                        <div class="form-group">
                                            <label class="sr-only"></label>
                                            <select class="form-control" name="selAccountQuery">
                                                <option value="">选择账户</option>
                                                @foreach (var account in Model.Accounts)
                                                {
                                                    <option value="@account.Id">@account.Name</option>
                                                }
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label class="sr-only"></label>
                                            <select class="form-control" name="selProjectQuery">
                                                <option value="">选择项目</option>
                                                @foreach (var project in lstProjects)
                                                {
                                                    <option value="@project.Id">@project.Name</option>
                                                }
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label class="sr-only"></label>
                                            <select class="form-control" name="selMemberQuery">
                                                <option value="">选择成员</option>
                                                @foreach (var member in lstMembers)
                                                {
                                                    <option value="@member.Id">@member.Name</option>
                                                }
                                            </select>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <div id="billAll" name="billlist">
                            @Html.Partial("_BillList", Model)
                        </div>
                    </div>
                    <div role="tabpanel" class="tab-pane J_Tab" data-billtype="@BillDetailType.Expend.GetHashCode()" id="tab1">
                        <div class="ibox float-e-margins J_hide">
                            <div class="ibox-title ibox-title-bill">
                                <h5 class="text-danger">查询条件</h5>
                                <div class="ibox-tools">
                                    <div class="btn-group">
                                        <button name="btnLastedWeek" data-querytype="1" type="button" class="btn btn-xs btn-white active">最近一周</button>
                                        <button name="btnLastedMonth" data-querytype="2" type="button" class="btn btn-xs btn-white">最近一月</button>
                                    </div>

                                    <a class="collapse-link ui-sortable">
                                        <i class="fa fa-chevron-up"></i>
                                    </a>
                                </div>
                            </div>
                            <div class="ibox-content">
                                <form class="form-inline">
                                    <div class="form-group">
                                        <div class="input-daterange input-group" id="datepicker">
                                            <input type="text" class="input-sm form-control" name="start" value="@DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd")" />
                                            <span class="input-group-addon">to</span>
                                            <input type="text" class="input-sm form-control" name="end" value="@DateTime.Now.ToString("yyyy-MM-dd")" />
                                            <span class="input-group-btn">
                                                <button name="btnDateQuery" type="button" class="btn btn-primary btn-sm "><i class="fa fa-search"></i></button>
                                            </span>
                                        </div>
                                        <div class="input-group">
                                            <select class="input-sm form-control" name="selFirstCategoryQuery">
                                                <option value="0">一级类别</option>
                                                @foreach (var first in lstExpends)
                                                {
                                                    <option value="@first.Id">@first.Name</option>
                                                }
                                            </select>
                                            <span class="input-group-addon">-</span>
                                            <select class="input-sm form-control" name="selCategoryQuery">
                                                <option value="0">二级类别</option>
                                                @{
                                                    var lstSeconds = Model.Categories.Where(c => c.ParentId == lstExpends.First().Id).OrderByDescending(c => c.IsCommonUse);
                                                }
                                                @foreach (var second in lstSeconds)
                                                {
                                                    <option value="@second.Id">@second.Name</option>
                                                }
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label class="sr-only"></label>
                                            <select class="form-control" name="selAccountQuery">
                                                <option value="">选择账户</option>
                                                @foreach (var account in Model.Accounts)
                                                {
                                                    <option value="@account.Id">@account.Name</option>
                                                }
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label class="sr-only"></label>
                                            <select class="form-control" name="selProjectQuery">
                                                <option value="">选择项目</option>
                                                @foreach (var project in lstProjects)
                                                {
                                                    <option value="@project.Id">@project.Name</option>
                                                }
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label class="sr-only"></label>
                                            <select class="form-control" name="selMemberQuery">
                                                <option value="">选择成员</option>
                                                @foreach (var member in lstMembers)
                                                {
                                                    <option value="@member.Id">@member.Name</option>
                                                }
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label class="sr-only"></label>
                                            <select class="form-control" name="selBaoXiao">
                                                <option value="">选择报销</option>
                                                <option value="0">非报销</option>
                                                <option value="1">待报销</option>
                                                <option value="2">已报销</option>
                                            </select>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                        
                        <div name="billlist">
                        </div>
                    </div>
                    <div role="tabpanel" class="tab-pane J_Tab" data-billtype="@BillDetailType.Income.GetHashCode()" id="tab2">
                        <div class="ibox float-e-margins J_hide">
                            <div class="ibox-title ibox-title-bill">
                                <h5 class="text-danger">查询条件</h5>
                                <div class="ibox-tools">
                                    <div class="btn-group">
                                        <button name="btnLastedWeek" type="button" class="btn btn-xs btn-white active hide">最近一周</button>
                                        @*<button name="btnLastedMonth" type="button" class="btn btn-xs btn-white">最近一月</button>*@
                                    </div>

                                    <a class="collapse-link ui-sortable">
                                        <i class="fa fa-chevron-up"></i>
                                    </a>
                                </div>
                            </div>
                            <div class="ibox-content">
                                <form class="form-inline">
                                    <div class="form-group">
                                        <div class="input-daterange input-group" id="datepicker">
                                            <input type="text" class="input-sm form-control" name="start" value="@(new DateTime(DateTime.Now.Year,1,1).ToString("yyyy-MM-dd"))" />
                                            <span class="input-group-addon">to</span>
                                            <input type="text" class="input-sm form-control" name="end" value="@DateTime.Now.ToString("yyyy-MM-dd")" />
                                            <span class="input-group-btn">
                                                <button name="btnDateQuery" type="button" class="btn btn-primary btn-sm "><i class="fa fa-search"></i></button>
                                            </span>
                                        </div>
                                        <div class="input-group">
                                            <select class="input-sm form-control" name="selFirstCategoryQuery">
                                                <option value="0">一级类别</option>
                                                @foreach (var first in lstIncomes)
                                                {
                                                    <option value="@first.Id">@first.Name</option>
                                                }
                                            </select>
                                            <span class="input-group-addon">-</span>
                                            <select class="input-sm form-control" name="selCategoryQuery">
                                                <option value="0">二级类别</option>
                                                @{
                                                    var lstChildsIncome = Model.Categories.Where(c => c.ParentId == lstIncomes.First().Id).OrderByDescending(c => c.IsCommonUse);
                                                }
                                                @foreach (var second in lstChildsIncome)
                                                {
                                                    <option value="@second.Id">@second.Name</option>
                                                }
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label class="sr-only"></label>
                                            <select class="form-control" name="selAccountQuery">
                                                <option value="">选择账户</option>
                                                @foreach (var account in Model.Accounts)
                                                {
                                                    <option value="@account.Id">@account.Name</option>
                                                }
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label class="sr-only"></label>
                                            <select class="form-control" name="selProjectQuery">
                                                <option value="">选择项目</option>
                                                @foreach (var project in lstProjects)
                                                {
                                                    <option value="@project.Id">@project.Name</option>
                                                }
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label class="sr-only"></label>
                                            <select class="form-control" name="selMemberQuery">
                                                <option value="">选择成员</option>
                                                @foreach (var member in lstMembers)
                                                {
                                                    <option value="@member.Id">@member.Name</option>
                                                }
                                            </select>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <div name="billlist">
                        </div>
                    </div>
                    <div role="tabpanel" class="tab-pane J_Tab" data-billtype="@BillDetailType.Transfer.GetHashCode()" id="tab3">
                        <div class="ibox float-e-margins J_hide">
                            <div class="ibox-title ibox-title-bill">
                                <h5 class="text-danger">查询条件</h5>
                                <div class="ibox-tools">
                                    <div class="btn-group">
                                        <button name="btnLastedWeek" data-querytype="1" type="button" class="btn btn-xs btn-white active">最近一周</button>
                                        <button name="btnLastedMonth" data-querytype="2" type="button" class="btn btn-xs btn-white">最近一月</button>
                                    </div>

                                    <a class="collapse-link ui-sortable">
                                        <i class="fa fa-chevron-up"></i>
                                    </a>
                                </div>
                            </div>
                            <div class="ibox-content">
                                <form class="form-inline">
                                    <div class="form-group">
                                        <div class="input-daterange input-group" id="datepicker">
                                            <input type="text" class="input-sm form-control" name="start" value="@DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd")" />
                                            <span class="input-group-addon">to</span>
                                            <input type="text" class="input-sm form-control" name="end" value="@DateTime.Now.ToString("yyyy-MM-dd")" />
                                            <span class="input-group-btn">
                                                <button name="btnDateQuery" type="button" class="btn btn-primary btn-sm "><i class="fa fa-search"></i></button>
                                            </span>
                                        </div>
                                        <div class="input-group">
                                            <select class="input-sm form-control" name="selAccountQuery">
                                                <option value="0">转出账户</option>
                                                @foreach (var account in Model.Accounts)
                                                {
                                                    <option value="@account.Id">@account.Name</option>
                                                }
                                            </select>
                                            <span class="input-group-addon">-</span>
                                            <select class="input-sm form-control" name="selAccountToQuery">
                                                <option value="0">转入账户</option>
                                                @foreach (var account in Model.Accounts)
                                                {
                                                    <option value="@account.Id">@account.Name</option>
                                                }
                                            </select>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <div name="billlist">
                        </div>
                    </div>
                    <div role="tabpanel" class="tab-pane J_Tab" data-billtype="@BillDetailType.Creditor.GetHashCode()" id="tab4">
                        <div class="ibox float-e-margins J_hide">
                            <div class="ibox-title ibox-title-bill">
                                <h5 class="text-danger">查询条件</h5>
                                <div class="pull-right">
                                    <select class="" name="selCreditorTypeQuery">
                                        <option value="0">借贷类型</option>
                                        <option value="1">借入</option>
                                        <option value="2">借出</option>
                                        <option value="3">收款</option>
                                        <option value="4">还款</option>
                                    </select>
                                </div>
                                <button name="btnLastedWeek" type="button" class="btn btn-xs btn-white active hide">最近一周</button>
                                @*<div class="ibox-tools">
                                    <div class="btn-group">
                                        <button name="btnLastedWeek" type="button" class="btn btn-xs btn-white active hide">最近一周</button>
                                        <button name="btnLastedMonth" data-querytype="2" type="button" class="btn btn-xs btn-white">最近一月</button>
                                    </div>
                                    
                                    <a class="collapse-link ui-sortable">
                                        <i class="fa fa-chevron-up"></i>
                                    </a>
                                </div>*@
                                
                            </div>
                            @*<div class="ibox-content">
                                <form class="form-inline">
                                    <div class="form-group">
                                        <div class="input-daterange input-group" id="datepicker">
                                            <input type="text" class="input-sm form-control" name="start" value="@DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd")" />
                                            <span class="input-group-addon">to</span>
                                            <input type="text" class="input-sm form-control" name="end" value="@DateTime.Now.ToString("yyyy-MM-dd")" />
                                            <span class="input-group-btn">
                                                <button name="btnDateQuery" type="button" class="btn btn-primary btn-sm "><i class="fa fa-search"></i></button>
                                            </span>
                                        </div>
                                        
                                        <div class="form-group">
                                            <label class="sr-only"></label>
                                            <select class="form-control" name="selCreditorTypeQuery">
                                                <option value="1">借贷类型</option>
                                                <option value="1">借入</option>
                                                <option value="2">借出</option>
                                                <option value="3">收款</option>
                                                <option value="4">还款</option>
                                            </select>
                                        </div>
                                        
                                    </div>
                                </form>
                            </div>*@
                        </div>
                        <div name="billlist">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>

@section scripts{
    <script src="~/Scripts/plugins/iCheck/icheck.min.js"></script>
    @*<script src="~/Scripts/plugins/datetimepicker/jquery.datetimepicker.js"></script>*@
    <script src="~/Scripts/plugins/datapicker/bootstrap-datepicker.js"></script>
    @*<script src="~/Scripts/plugins/mobiscroll/mobiscroll.core-2.5.2.js"></script>*@
    <script type="text/javascript" src="~/Scripts/plugins/mobiscroll/mobiscroll.custom-2.5.2.min.js"></script>
    <script type="text/javascript" src="~/Scripts/plugins/mobiscroll/mobiscroll.datetime-2.5.1.js"></script>
    <script type="text/javascript" src="~/Scripts/plugins/mobiscroll/mobiscroll.datetime-2.5.1-zh.js"></script>

    <script>
        window.categories = @Html.Raw(strCategories);
    </script>
    <script src="~/Scripts/licai/detail.js"></script>
}